//
//  SEGAboutUsViewController.m
//  ExcellentHome
//
//  Created by 陈区 on 14-1-11.
//  Copyright (c) 2014年 陈区. All rights reserved.
//
#import "SEGAboutUsViewController.h"
#import "SEGAboutUsViewModel.h"
@interface SEGAboutUsViewController ()
@property(nonatomic, strong) SEGAboutUsViewModel *viewModel;
@end

@implementation SEGAboutUsViewController

- (void)setupUI {
    self.title = @"关于";
    
    UIImageView* imageView = [[UIImageView alloc] init];
    imageView.image = [UIImage imageWithContentsOfFile:SEGPicName(@"AppIcon60_corner")];
    [self.view addSubview:imageView];
    [imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.height.mas_equalTo(60);
        make.centerX.mas_offset(0);
        make.top.mas_equalTo(76);
    }];
    
    
    UILabel *appNameLabel = ({
        UILabel *label = [[UILabel alloc] init];
        [self.view addSubview:label];
        label.textColor = kColor_1;
        label.font = kFont_16;
        label.text = kAppName;
        label;
    });;
    [appNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(imageView.mas_bottom).offset(14);
        make.centerX.equalTo(imageView);
    }];
 
    UILabel *versionLabel = ({
        UILabel *label = [[UILabel alloc] init];
        [self.view addSubview:label];
        label.textColor = kColor_3;
        label.font = kFont_10;
        label.text = [NSString stringWithFormat:@"版本 v%@", [SEGUtils segBundleShortVersionString]];;
        label;
    });
    [versionLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(-132);
        make.centerX.offset(0);
    }];
    
    UIButton *serverOrdinanceButton = ({
        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
        NSString *title = [NSString stringWithFormat:@"%@用户协议",kAppName];
        [button setTitle:title forState:UIControlStateNormal];
        [button setTitleColor:[UIColor colorWithHexString:@"#2170B3"] forState:UIControlStateNormal];
        button.titleLabel.font = kFont_13;
        [button addTarget:self action:@selector(ordinanceBtnTap:) forControlEvents:UIControlEventTouchUpInside];
        [self.view addSubview:button];
        button;
    });
    [serverOrdinanceButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(-86);
        make.centerX.mas_offset(0);
        make.height.mas_equalTo(30);
    }];
    
    UIView *underLine1 = [[UIView alloc] init];
    underLine1.backgroundColor = [UIColor colorWithHexString:@"2170B3"];
    [self.view addSubview:underLine1];
    [underLine1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(0.5);
        make.width.equalTo(serverOrdinanceButton.mas_width);
        make.top.equalTo(serverOrdinanceButton.mas_bottom).offset(-8);
        make.centerX.equalTo(serverOrdinanceButton);
    }];
    
    
    UIButton *securityButton = ({
        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
        NSString *title = [NSString stringWithFormat:@"%@隐私政策",kAppName];
        [button setTitle:title forState:UIControlStateNormal];
        [button setTitleColor:[UIColor colorWithHexString:@"#2170B3"] forState:UIControlStateNormal];
        button.titleLabel.font = kFont_13;
        [button addTarget:self action:@selector(securityBtnTap:) forControlEvents:UIControlEventTouchUpInside];
        [self.view addSubview:button];
        button;
    });
    [securityButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(-58);
        make.centerX.mas_offset(0);
        make.height.mas_equalTo(30);
    }];
    
    UIView *underLine2 = [[UIView alloc] init];
    underLine2.backgroundColor = [UIColor colorWithHexString:@"2170B3"];
    [self.view addSubview:underLine2];
    [underLine2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(0.5);
        make.width.equalTo(securityButton.mas_width);
        make.top.equalTo(securityButton.mas_bottom).offset(-8);
        make.centerX.equalTo(securityButton);
    }];
 
    
}


- (void)viewDidLoad {
    [super viewDidLoad];
    [self setupUI];
    [self showCustomNavigationBackButton];
    
    [self segInitViews];
    [self bindViewModel];
}

- (void)ordinanceBtnTap:(id)sender {
    NSDictionary *params = @{@"linkURL":kUhomeUseRegulation};
    UIViewController *VC = [[SEGUhomeMediator sharedInstance]seg_initWebViewLoadController:params];
    VC.title = [NSString stringWithFormat:@"%@使用服务条例",kAppName];
    [self.navigationController pushViewController:VC animated:YES];
}

- (void)securityBtnTap:(UIButton *)sender {
    NSString *urlStr = [NSString stringWithFormat:@"%@%@?app_platform_code=%@&company_platform_code=%@",kClientRootURL,@"/h5/policy/policy.html",kAppPlatformCode,kAppPlatformCode];
    NSDictionary *params = @{@"linkURL":urlStr};
    UIViewController *vc = [[SEGUhomeMediator sharedInstance] seg_initWebViewLoadController:params];
    vc.title = [NSString stringWithFormat:@"%@隐私政策", kAppName];
    [self.navigationController pushViewController:vc animated:YES];
}
   
#pragma mark - Init Views
-(void)segInitViews{}

#pragma mark - Layout
- (void)updateViewConstraints {
    [super updateViewConstraints];
}

#pragma mark - Private Methods

#pragma mark - RAC Data Binding
- (void)bindViewModel {}

#pragma mark - getter
-(SEGAboutUsViewModel *)viewModel{
    if (!_viewModel) {
        _viewModel = [[SEGAboutUsViewModel alloc]init];
    }
    return _viewModel;
}
#pragma mark setter
@end
